import os

import openpyxl
import TryDButils as DB

class Data:

    def readExcel(self,sheetname):
        # 获取工作簿对象
        print(os.getcwd())
        wb = openpyxl.load_workbook('./WebAuto/Data/度小满理财.xlsx')
        # 获取工作表对象
        sheet = wb[f'{sheetname}']
        data = []
        list = []
        for i in sheet.rows:
            for c in i:
                list.append(c.value)
            data.append(list)
            list = []
        return data
    def  DBconnect(self):
        db=DB.DatabseManager(host='localhost', port=3306, user='root', password='root', database='finance',
                 charset='utf8')
        return db
    def select(self,sql):
        db=self.DBconnect()
        db.execute(sql)
        data=db.cursor.fetchone()
        result=data[0]
        return result
